import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    sessionId: "",
    CPU: {},
    GPU: {},
    MEM: {},
    FPGA: {},
    PACKET: {},
    COMMAND:{},
    PCAP:[],
    P4COMMAND:{},
  },
  mutations: {
    saveSessionId(state, sessionId) {
      state.sessionId = sessionId;
    },
    saveData(state, data) {
      switch (data.type) {
        case "CPU":
          state.CPU = data.data;
          break;
        case "GPU":
          state.GPU = data.data;
          break;
        case "MEM":
          state.MEM = data.data;
          break;
        case "PACKET":
          state.PACKET = data.data;
          break;
        case "FPGA":
          state.FPGA = data.data;
          break;
        case "COMMAND":
          state.COMMAND = data.data.msg;
          break;
        case "PCAP":
          state.PCAP = [...state.PCAP,...data.data]
          console.log(state.PCAP);
          break;
        case "P4COMMAND":
          state.P4COMMAND = data.data.msg;
          break;
      }
      
    },
  },
  actions: {},
});
